/* rcslb02.p - DO STAGE OPEN QTY FOR A SCHEDULED ORDER LINE             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.3.3 $                                                   */
/*V8:ConvertMode=NoConvert                                              */
/* REVISION: 7.5    LAST MODIFIED: 03/13/95           BY: GWM *J049*    */
/* REVISION: 8.5    LAST MODIFIED: 07/17/96    BY: *J0XM* Robert Wachowicz*/
/* REVISION: 8.6    LAST MODIFIED: 09/16/96   BY: *K003* Vinay Nayak-Sujir */
/* REVISION: 8.6    LAST MODIFIED: 09/27/96   BY: *K003* forrest mori      */
/* REVISION: 8.6    LAST MODIFIED: 11/18/97   BY: *K18W* Taek-Soo Chang */
/* REVISION: 8.6E   LAST MODIFIED: 06/08/98   BY: *J2MH* Dana Tunstall  */
/* REVISION: 9.1    LAST MODIFIED: 06/14/99   BY: *N004* Patrick Rowan  */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* myb               */
/* $Revision: 1.7.3.3 $    BY: Kaustubh K.    DATE: 08/30/01 ECO: *M13W*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* INPUT PARAMETERS */
define input parameter sod_recno as recid no-undo.
define input parameter open_qty like sod_qty_ord no-undo.
define input parameter shipgrp like sg_grp no-undo.
define input parameter inv_mov like abs_inv_mov no-undo.
define input parameter nrseq like abs_preship_nr_id no-undo.
define input parameter cons_ship like abs_cons_ship no-undo.
define input parameter l_create_um like mfc_logical  no-undo.
define input parameter stage_open  like mfc_logical  no-undo.

/* SHARED VARIABLES FOR CUSTOMER SEQUENCE SCHEDULES */
{sosqvars.i}

find sod_det where recid(sod_det) = sod_recno no-lock.

find pt_mstr where pt_part = sod_part no-lock no-error.

find qad_wkfl where qad_key1 = mfguser + global_db + "stage_list"
   and qad_key2 = sod_nbr + string(sod_line) no-lock no-error.

if not available qad_wkfl then do:

   find so_mstr where so_nbr = sod_nbr no-lock.

   create qad_wkfl.

   assign
      qad_key1 = mfguser + global_db + "stage_list"
      qad_key2 = sod_nbr + string(sod_line)
      qad_decfld[1] = if (    sod_type    <> ""
                          and sod_qty_all <> 0
                          and not stage_open)
                      then
                         sod_qty_all
                      else
                         open_qty * sod_um_conv
      qad_decfld[3] = if (    sod_type    <> ""
                          and sod_qty_all <> 0
                          and not stage_open)
                      then
                         sod_qty_all
                      else
                         0
      qad_charfld[1] = so_site
      qad_charfld[2] = sod_part
      qad_charfld[3] = sod_loc
      qad_charfld[6] = so_ship
      qad_charfld[7] = sod_nbr
      qad_charfld[8] = string(sod_line)
      qad_charfld[10] = if not l_create_um and available pt_mstr
                        then
                           pt_um
                        else
                           sod_um
      qad_charfld[11] = if not l_create_um and available pt_mstr
                        then
                           string("1")
                        else
                           string(sod_um_conv)
      qad_charfld[12] = sod_site
      qad_charfld[13] = shipgrp + "," + inv_mov
      qad_charfld[14] = nrseq + "," + cons_ship.

   if using_seq_schedules and so_seq_order then do:
      /*CREATE SEQ. STAGE LIST ENTRIES (qad_wkfl) */
      {gprunmo.i
         &program = ""rcslb03.p""
         &module = "ASQ"
         &param = """(input sod_nbr,
                      input sod_line,
                      input recid(qad_wkfl),
                      input yes)"""}
   end.  /* if using_seq_schedules */

end.
